
import React, { Component } from "react";
import './index.css'
class MyHeader extends Component {
    state = {
        searchText: ''
    }
    keyUp = (event) => {
        let { target, keyCode } = event
        if (keyCode !== 13 || !target.value) return
        this.setState({
            searchText: target.value
        })
        this.props.setItems(target.value)
        target.value = ''
    }
    render() {
        return (<div className="header-container">
            <input onKeyUp={this.keyUp} type="text" placeholder="请输入" className="inp"></input>
            <input type="button" onClick={ } value="搜索" className="btn"></input>
        </div>)
    }
}
export default MyHeader